package com.play.ballen.home.ui

import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.annotation.RequiresApi
import com.play.ballen.R
import com.play.ballen.databinding.ActivityDialogKeyboardAddBinding
import com.play.ballen.databinding.ActivityDialogKeyboardBinding
import com.play.ballen.event.EventCost
import com.play.ballen.home.vm.PLPFragmentVM
import com.yuven.appframework.util.imageloader.ImageUtil
import com.yuven.baselib.component.BaseMVVMActivity
import com.yuven.baselib.component.eventbus.Event
import com.yuven.baselib.component.eventbus.EventBusUtil
import org.kymjs.chat.OnOperationListener
import org.kymjs.chat.bean.Emojicon
import org.kymjs.chat.bean.Faceicon
import org.kymjs.chat.emoji.DisplayRules
import java.io.File

class KeyboardActivity : BaseMVVMActivity<PLPFragmentVM, ActivityDialogKeyboardAddBinding>() {

    private var longitude = 0.0
    private var latitude = 0.0

    var moment_id = 0//回复某评论填该评论id, 否则填0
    var parent_id = 0//父评论的id, 没有填0
    var target_id = 0//回复某评论填该评论id, 否则填0
    var reply_person = ""
    override fun layoutId(): Int {
        return R.layout.activity_dialog_keyboard_add
    }

    override fun viewModelClass(): Class<PLPFragmentVM> {
        return PLPFragmentVM::class.java
    }

    companion object {
        @JvmStatic
        fun start(context: Context) {
            val starter = Intent(context, KeyboardActivity::class.java)
            context.startActivity(starter)
        }
    }

    override fun initIntent(intent: Intent?) {
        if (intent != null) {
        }
    }


    @RequiresApi(Build.VERSION_CODES.O)
    override fun initObserver() {
        super.initObserver()
    }

    override fun initView() {
    }

    override fun initData() {
        dataBinding.llContent.setOnClickListener{
            finish()
        }

        dataBinding.chatMsgInputBox.setOnOperationListener(object : OnOperationListener {
            override fun send(content: String) {

            }

            override fun selectedFace(content: Faceicon) {

            }

            override fun selectedEmoji(str: String?, faceImageRes: Int) {
                TODO("Not yet implemented")
            }

//            override fun selectedEmoji(emoji: Emojicon) {
//                EventBusUtil.post(Event.create(EventCost.ADD_BOTTOLE_FACE,emoji.value))
//            }

            override fun selectedBackSpace(back: Emojicon) {
//                DisplayRules.backspace(  dataBinding.chatMsgInputBox.editTextBox)
            }

            override fun selectedFunction(index: Int) {
                when (index) {
//                    0 -> goToAlbum()
//                    1 -> Toast.makeText(applicationContext, "跳转相机，只做演示", Toast.LENGTH_SHORT).show()
                }
            }
        })

        val faceCagegory: MutableList<String> = ArrayList()
        val faceList = File("")
        if (faceList.isDirectory) {
            val faceFolderArray = faceList.listFiles()
            for (folder in faceFolderArray) {
                if (!folder.isHidden) {
                    faceCagegory.add(folder.absolutePath)
                }
            }
        }
        dataBinding.chatMsgInputBox.setFaceData(faceCagegory)
        dataBinding.chatMsgInputBox.showFace()
    }




}